package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.MemberCardForm;
import com.springboot.cloud.demos.entity.form.MemberCardQueryForm;
import com.springboot.cloud.demos.entity.param.MemberCardQueryParam;
import com.springboot.cloud.demos.entity.po.MemberCard;
import com.springboot.cloud.demos.ribbon.service.MemberCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class MemberCardController {

    @Autowired
    private MemberCardService memberCardService;

    @PostMapping("/conditions")
    public Result conditions(@RequestBody MemberCardQueryForm params) {
        return memberCardService.conditions(params);
    }

    @PostMapping("/memberCard")
    public Result add(@RequestBody MemberCardForm memberCardForm) {
        return memberCardService.save(memberCardForm);
    }

    @PutMapping(value = "/memberCard")
    public Result update(@RequestBody MemberCardForm memberCard) {
        return memberCardService.update(memberCard);
    }

    @GetMapping("/memberCard/{memberCardId}")
    public Result<MemberCard> get(@PathVariable(value = "memberCardId") String memberCardId) {
        return memberCardService.memberCard(memberCardId);
    }

    @DeleteMapping("/memberCard/{memberCardId}")
    public Result delete(@PathVariable(value = "memberCardId") String memberCardId) {
        return memberCardService.delete(memberCardId);
    }

}
